import http from "../../../utils/http"
Page({

  data: {
    detail: {
      title: "",
      type: "",
      content: "",
      author: "",
      createTime: "",
    }
  },
  onLoad(options) {
    if (options.id) {
      this.getBlogDetail(options.id);
    }
  },
  async getBlogDetail(id) {
    try {
      const res = await http.get("/blog/info/" + id);
      if (res.code === 200) {
        this.setData({
          detail: res.data
        })
      }
    } catch (error) {
      wx.showToast({
        title: "服务器错误",
        icon: 'none'
      });
    }
  },
  onClickLeft() {
    wx.switchTab({
      url: '/pages/index/index',
    })
  }

})